﻿<%@ WebHandler Language="C#" Class="piece_list" %>

using System;
using System.Web;
using System.Web.SessionState;
using TSqlServer;

public class piece_list : IHttpHandler, IReadOnlySessionState
{
    
    public void ProcessRequest (HttpContext context) {
        string sid = context.Session["ecrm_uid"].ToString();

        context.Response.ContentType = "text/plain";
        context.Response.Write(piecelist(sid));
        context.Response.End();
    }
 
    public bool IsReusable {
        get {
            return false;
        }
    }

    private string piecelist(string sid)
    {
        string result = "<table id=\"pieces\" cellSpacing=\"1\" cellPadding=\"0\" width=\"90%\" align=\"center\" border=\"0\" class=\"tablesorter\">";
        result += "<thead>";
        result += "<tr height=26>";
        result += "<th width=40 align=left>序号</th>";
        result += "<th align=left>名称</th>";
        result += "<th width=40></th>";
        result += "</tr>";
        result += "</thead>";

        int iRow = 1;
        result += "<tbody>";
        string sSql = "select uid,piecename from t_cms_piece where status=0 and inman='" + sid + "' order by iid desc";
        TSqlDBReader myReader = new TSqlDBReader(sSql);
        while (myReader.FDataReader.Read())
        {
            result += "<tr height=26>";
            result += "<td width=40 align=center>" + iRow.ToString() + "</td>";
            result += "<td><span onclick=\"piece_get('" + myReader.FDataReader.GetValue(0).ToString() + "')\" style=\"cursor: hand;\">" + myReader.FDataReader.GetValue(1).ToString() + "</span></td>";
            result += "<td align=center><span onclick=\"piece_remove('" + myReader.FDataReader.GetValue(0).ToString() + "')\" style=\"cursor: hand;\">删除</span></td>";
            result += "</tr>";
            iRow++;
        }
        myReader.Free();
        result += "<tbody>";

        result += "</table>";

        return result;
    }
}